package ssx.demo.redisson_redlock_demo;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import ssx.demo.redisson_redlock_demo.service.ServiceRedis;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

@SpringBootTest
public class Demo {

    @Autowired
            @Qualifier("myServiceRedis")
    ServiceRedis serviceRedis;

    @Test
    public void fu(){
        //测试多线程测试
        String yyyyMMdd = new SimpleDateFormat("yyyyMMdd").format(new Date());
        String wyyyyMMdd = new SimpleDateFormat("YYYYMMdd").format(new Date());

        Long aLong = 123L;
        String s = new DecimalFormat("0000").format(aLong);
        String s2 = new DecimalFormat("000000").format(aLong);
        String s3 = new DecimalFormat("00").format(aLong);
        String s4 = new DecimalFormat("0").format(aLong);
        String s5 = new DecimalFormat().format(aLong);



        serviceRedis.curd();

        //定义100个线程
        ArrayList<Runnable> list = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            Runnable runnable=()->{
                serviceRedis.fun();
            };
            list.add(runnable);
        }

        //执行100个线程
        list.forEach((v)->{new Thread(v).start();});

        //保证main线程一直在线
        while (true){

        }
    }
}
